import { createRouter, createWebHashHistory, createWebHistory } from "vue-router"
import { useLoginStore } from '@/stores/login'
const routes = [
  {
    path: '/',
    name: 'layout',
    redirect: { name: 'Home' },
    component: () => import('../views/layout.vue'),
    children: [
      {
        path: '/home',
        name: 'Home',
        component: () => import('../views/Home/index.vue')
      },
      {
        path: '/studyCenter',
        name: 'StudyCenter',
        component: () => import('../views/StudyCenter/index.vue')
      },
      {
        path: '/products',
        name: 'Products',
        component: () => import('../views/Products/index.vue'),
      },
      {
        path: '/products/design',
        name: 'design',
        component: () => import('../views/Products/pages/design.vue'),
      },
      {
        path: '/products/detail',
        name: 'detail',
        component: () => import('../views/Products/pages/detail.vue'),
      },
      {
        path: '/products/list',
        name: 'list',
        component: () => import('../views/Products/pages/list.vue'),
      },
      {
        path: '/myProduct/list',
        name: 'myProductList',
        component: () => import('../views/MyProduct/index.vue'),
      },
      {
        path: '/notification',
        name: 'notification',
        component: () => import('../views/Notification/index.vue'),
      },
      {
        path: '/myProduct/payment',
        name: 'payment',
        component: () => import('../views/MyProduct/payment.vue'),
      },
      {
        path: '/order/list',
        name: 'order',
        component: () => import('../views/OrderManagement/index.vue'),
      },
      {
        path: '/order/detail',
        name: 'orderDetail',
        component: () => import('../views/OrderManagement/detail.vue'),
      },
      {
        path: '/user',
        name: 'index',
        component: () => import('../views/User/index.vue'),
        children: [
          {
            path: 'my',
            name: 'my',
            component: () => import('../views/User/my.vue'),
          },
          {
            path: 'address',
            name: 'address',
            component: () => import('../views/User/address.vue'),
          }
        ]
      }
    ],
  },
  {
    path: '/design',
    name: 'design',
    component: () => import('../views/Design/index.vue'),
  },
]
const router = createRouter({
  history: createWebHistory(),
  routes
})
router.beforeEach(async (to,from,next)=>{
  console.log(useLoginStore.isLoggedIn)
  next()
})

export default router